/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Inrterface;

import Map.MapConfig;
import java.util.LinkedList;
import java.util.Stack;
import jcgame.Main;

/**
 *
 * @author insane
 */
public class Messages {

    private LinkedList message;
    
    private int width = MapConfig.getInstance().getViewSizeWidth() * 2 + MapConfig.getInstance().getPadding_left();
    private int height = MapConfig.getInstance().getScreenHeight() - MapConfig.getInstance().getViewSizeHeight() * 2 - MapConfig.getInstance().getPadding_top() - 4;
    private static Messages instance = null;

    public static Messages getInstance() {
        if (instance == null) {
            instance = new Messages();
        }
        return instance;
    }

    private Messages() {
        message = new LinkedList();
    }

    public void draw() {
        for (int i = 0; i < message.size(); i++) {
            Main.csi.print(MapConfig.getInstance().getPadding_left() + 2, MapConfig.getInstance().getViewSizeHeight() * 2 + MapConfig.getInstance().getPadding_top() + 2 + i, (String) message.get(i));
        }
    }

    public void add(String text) {
        if(message.size() >= height) message.removeLast();
        message.addFirst(text);
    }

    /**
     * @return the width
     */
    public int getWidth() {
        return width;
    }

    /**
     * @return the height
     */
    public int getHeight() {
        return height;
    }
}
